package View;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.EmptyBorder;

/**
 * 
 * @author stephenbwilliamson
 */
public class VisualizationPanel extends JPanel {

	private static final long serialVersionUID = 1561061975507210790L;
	private static VisualizationPanel instance = null;
	private JPanel geneView;
	private JPanel subset0View;
	private JScrollPane subsetPane;

	protected VisualizationPanel() {
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		geneView = GeneViewport.getInstance();
		subset0View = Subset0Viewport.getInstance();

		subsetPane = new JScrollPane(subset0View,
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		subsetPane.setBorder(new EmptyBorder(0, 0, 10, 0));
		
		geneView.setSize(new Dimension(getWidth(), getHeight()*7/10));
		subsetPane.setSize(new Dimension(getWidth(), getHeight()*3/10));
		
		this.add(geneView);
		this.add(subsetPane);
		this.validate();
	}

	public static VisualizationPanel getInstance() {
		if (instance == null) {
			instance = new VisualizationPanel();
		}
		return instance;
	}

	@Override
	public void repaint() {
		if (geneView == null | subset0View == null) {
			return;
		}
		
		geneView.repaint();
		subsetPane.repaint();
	}
}
